/*
 * Copyright (C) 2008-2011 University of Deusto
 * 
 * All rights reserved.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution.
 * 
 * This software consists of contributions made by many individuals, 
 * listed below:
 *
 * Author: Aitor Gómez Goiri <aitor.gomez@deusto.es>
 */
package otso.se.network.sockets.communication;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

import otso.se.network.sockets.communication.abstraction.AbstractSocketApplication;
import otso.se.network.sockets.communication.resources.graphs.WildcardGraphResource;
import otso.se.network.sockets.communication.resources.query.WildcardQueryResource;
import otsopack.commons.IController;
import otsopack.full.java.network.communication.resources.prefixes.PrefixesStorage;

public class OtsopackSocketApplication extends AbstractSocketApplication {

	private static final String CONTROLLER_PROPERTY_NAME = "controller";
	private static final String TIMEOUT_PROPERTY_NAME    = "timeout";
	private static final Integer DEFAULT_TIMEOUT         = Integer.valueOf(5 * 1000);

	private final ConcurrentMap<String, Object> attributes = new ConcurrentHashMap<String, Object>();
	private final PrefixesStorage prefixesStorage = new PrefixesStorage();
	
	public OtsopackSocketApplication(){
		super.resources.add(WildcardGraphResource.class);
		super.resources.add(WildcardQueryResource.class);
		this.attributes.put(TIMEOUT_PROPERTY_NAME, DEFAULT_TIMEOUT);
	}
	
	public IController getController(){
		return (IController)this.attributes.get(CONTROLLER_PROPERTY_NAME);
	}
	
	public void setController(IController controller){
		this.attributes.put(CONTROLLER_PROPERTY_NAME, controller);
	}
	
	public PrefixesStorage getPrefixesStorage(){
		return this.prefixesStorage;
	}
}